Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement control flow graph construction #3037

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft

Conversation

HalidOdat
Copy link
Member

@HalidOdat HalidOdat commented Jun 13, 2023

This PR is a WIP implementation of control flow graph construction from bytecode, that will be used for many optimizations, like dead-code-elimination.

TODO

  • Add instruction information like length, does it push/pop, is it a jump, etc
  • Remove BasicBlock and redirect it's references
  • Insert BasicBlock and redirect it's references
  • Clean-up
  • Document

@HalidOdat HalidOdat added the performance Performance related changes and issues label Jun 13, 2023
@jedel1043
Copy link
Member

Nice! This'll also be really useful when we eventually implement JIT compilation

Copy link
Member

@Razican Razican left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great step :) I added a couple of comments, but I didn't do a full review yet

boa_cli/src/debug/optimizer.rs Outdated Show resolved Hide resolved
boa_engine/src/optimizer/cfg.rs Outdated Show resolved Hide resolved
@github-actions
Copy link

github-actions bot commented Jun 15, 2023

Test262 conformance changes

Test result main count PR count difference
Total 95,960 95,960 0
Passed 76,534 76,534 0
Ignored 18,477 18,477 0
Failed 949 949 0
Panics 0 0 0
Conformance 79.76% 79.76% 0.00%

@codecov
Copy link

codecov bot commented Jun 15, 2023

Codecov Report

Attention: 68 lines in your changes are missing coverage. Please review.

Comparison is base (0f82312) 48.88% compared to head (126367f) 49.34%.

Files Patch % Lines
...ore/engine/src/optimizer/control_flow_graph/mod.rs 90.15% 25 Missing ⚠️
cli/src/debug/optimizer.rs 0.00% 21 Missing ⚠️
...ne/src/optimizer/control_flow_graph/basic_block.rs 60.60% 13 Missing ⚠️
core/engine/src/vm/opcode/mod.rs 36.36% 7 Missing ⚠️
core/engine/src/vm/code_block.rs 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3037      +/-   ##
==========================================
+ Coverage   48.88%   49.34%   +0.46%     
==========================================
  Files         471      473       +2     
  Lines       48492    48814     +322     
==========================================
+ Hits        23705    24088     +383     
+ Misses      24787    24726      -61     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jedel1043
Copy link
Member

Coincidentally, I found this crate that could simplify the optimizer logic:
https://docs.rs/egg/0.9.5/egg

@HalidOdat
Copy link
Member Author

HalidOdat commented Jul 16, 2023

Coincidentally, I found this crate that could simplify the optimizer logic:
https://docs.rs/egg/0.9.5/egg

Looks interesting! But I think it would be better to create our own, because JS semantics are complex and it would be easier to extend.

I postponed this PR until #3059 is fully complete (currently refactoring generators, which are the remaining test262 failing tests).

@jedel1043 jedel1043 added the waiting-on-author Waiting on PR changes from the author label Nov 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Performance related changes and issues waiting-on-author Waiting on PR changes from the author
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants